<?php
declare (strict_types = 1);

namespace app\shop\controller;

use think\annotation\Route;
use think\annotation\route\Group;
use think\annotation\route\Middleware;
use app\common\service\SystemConfigService\Channel\ChannelConfigService;
use app\BaseShopController;
use think\Request;
/**
 * @Group("ChannelConfig")
 * @Middleware({shopMiddileware::class})
 */
class ChannelConfig extends BaseShopController
{
   /**
     * 获取配置项列表(分页)
     * @Route("getConfigListByPage",method="GET")
     * @return string
     */
    public function getConfigListByPage()
    {
        $result = callApi(ChannelConfigService::class, 'getConfigListByPage',$this->_all_data);
        return apiResponse($result);
    } 
    
    /**
     * 根据id获取配置项
     * @Route("getConfigById/:id",method="GET")
     * @return string
     */
    public function getConfigById($id)
    {
        $param=[
            'id'=>$id,
            'cid'=> $this->_master_user['cid']
        ];
        $result = callApi(ChannelConfigService::class, 'getConfigById',$param);
        return apiResponse($result);
    } 
    /**
     * 根据id修改配置项
     * @Route("editConfigById",method="PUT")
     * @return string
     */
    public function editConfigById()
    {
        $result = callApi(ChannelConfigService::class, 'editChannelConfigById', $this->_all_data);
        if($result['code']==\app\Normal::SUC){
            $this->log(['content'=>'修改业务配置id为【'.$this->_all_data['id'].'】信息','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    } 
    /**
     * 根据code获取配置项
     * @Route("getConfigByCode",method="GET")
     * @return string
     */
    public function getConfigByCode()
    {
        $result = callApi(ChannelConfigService::class, 'getConfigByCode', $this->_all_data);
        return apiResponse($result);
    } 
}
